import 'package:get/get.dart';
import 'package:flutter/widgets.dart';

class ProjectMainController extends GetxController {
  //TODO: Implement ProjectMainController

  int projectId = 0; // 替换 late int projectId
  RxInt currentTabIndex = 1.obs;

  List tabsList = [
    {"id": 1, "title": "接口列表"},
    // {"id": 2, "title": "成员管理"},
    // {"id": 3, "title": "项目动态"},
    // {"id": 4, "title": "项目设置"},
  ];
  @override
  void onInit() {
    super.onInit();
    // 安全获取参数
    var args = Get.arguments;
    // 修复后的代码
    if(args != null){
      projectId = args['projectId'];
    } else {
      // 使用延迟执行避免在构建过程中跳转
      WidgetsBinding.instance.addPostFrameCallback((_) {
        Get.offAllNamed("/home");
      });
      return;
    }
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }

  //改变顶部tab切换
  void changeSelectedTabsIndex(index) {
    currentTabIndex.value = index;
  }
}
